//执行登录页面的逻辑
let login_fn = async (cxt, next) => {
    //创建两个变量接收网页上的用户名和密码
    let username = cxt.request.body.username || '';
    let password = cxt.request.body.password || '';
    if (username === 'admin' && password === '123456') {
        //重定向
        cxt.response.redirect('/login/success');
    }else{
        cxt.response.redirect('/login/error');
    }
}
//登录成功提示
let success_fn=async(cxt,next)=>{
    cxt.response.body='登录成功！';
}
//登录失败提示
let error_fn=async(cxt,next)=>{
    cxt.response.body='账号或密码错误！';
}

//通过路由把这个文件暴露出去
module.exports={
    //定义上面两个函数的路由
    '/login/login':['post',login_fn],
    '/login/success':['get',success_fn],
    '/login/error':['get',error_fn]
}